{% extends 'rebs/layouts/base.html' %}

{% block title %}Rebs -  입출금 내역 등록{% endblock %}

{% block content %}
    {% load static widget_tweaks %}

    <!-- Start Content-->
    <div class="container-fluid">

        <!-- start page title -->
        {% include 'rebs/partials/content_title.html' with  second_bs="현장 자금 관리" title="입출금 내역 등록" %}
        <!-- end page title -->


        <div class="row">
            <form class="form-horizontal p-0 col-12" method="get">
                <div class="col-lg-12">
                    <div class="card">
                        <div class="card-body">

                            {% with menu_order='3' %}
                                {% include 'rebs_cash/partials/head_menu_p_cash.html' %}
                            {% endwith %}

                            <div class="row">
                                {% include 'rebs/partials/project_select.html' %}
                                <div class="col-sm-12 col-md-6"></div>
                            </div>
                        </div>
                    </div>
                </div>
            </form>

            <form method="POST" id="form1" class="col-12 needs-validation p-0" novalidate>
                {% csrf_token %}
                <input type="hidden" name="project" id="project" value="{{ this_project.id }}">

                <div class="col-lg-12">
                    <div class="card">
                        <div class="card-body pb-1">
                            <div class="row">
                                <div class="col-sm-12 col-md-6">
                                    <div class="form-group row mb-3">
                                        <label for="{{ form.deal_date.id_for_label }}"
                                               class="col-3 col-form-label text-center bg-info-lighten">{{ form.deal_date.label }}</label>
                                        <div class="col-9 col-md-8 col-lg-5">
                                            {{ form.deal_date|add_class:"form-control"|attr:"placeholder:거래일자"|attr:"data-provide=datepicker data-date-format=yyyy-mm-dd data-date-autoclose=true data-toggle=input-mask data-mask-format=0000-00-00" }}
                                        </div>
                                    </div>
                                </div>
                                <div class="col-sm-12 col-md-6"></div>
                            </div>

                            <div class="row">
                                <div class="form-group row table-responsive pl-2">
                                    <table class="table table-sm table-hover m-0">
                                        <thead>
                                        <tr>
                                            <th class="text-center">구분</th>
                                            <th class="text-center">현장 계정</th>
                                            <th class="text-center">세부 계정</th>
                                            <th class="text-center">적요</th>
                                            <th class="text-center">거래처</th>
                                            <th class="text-center">
                                                거래계좌
                                                <a href="#">
                                                    <i class="dripicons-gear"
                                                       data-toggle="popover"
                                                       data-trigger="hover"
                                                       data-placement="right" title=""
                                                       data-content="거래를 입력할 계좌가 등록되어 있지 않다면 새로 등록하세요."
                                                       data-original-title="계좌 등록"></i>
                                                </a>
                                            </th>
                                            <th class="text-center">입금액</th>
                                            <th class="text-center">출금액</th>
                                            <th class="text-center">비 고</th>
                                        </tr>
                                        </thead>

                                        {# 프로젝트 캐시북 폼셋 finish #}
                                        {{ formset.management_form }}

                                        <tbody class="empty-form" disabled style="display: none">
                                        <tr>
                                            <td class="text-center">
                                                <select name="form-__prefix__-cash_category1" class="form-control"
                                                        id="id_form-__prefix__-cash_category1"
                                                        onchange="category1_change(this)">
                                                    <option value="">---------</option>
                                                    <option value="1">입금</option>
                                                    <option value="2">출금</option>
                                                    <option value="3">대체</option>
                                                </select>
                                            </td>
                                            <td class="text-center">
                                                <select name="form-__prefix__-project_account_d1" required=""
                                                        class="form-control"
                                                        id="id_form-__prefix__-project_account_d1"
                                                        onchange="pa_d1_change(this)" disabled="">
                                                    <option value="" selected="">---------</option>
                                                </select>
                                            </td>
                                            <td class="text-center">
                                                <select name="form-__prefix__-project_account_d2" required=""
                                                        class="form-control"
                                                        id="id_form-__prefix__-project_account_d2" disabled="">
                                                    <option value="" selected="">---------</option>
                                                </select>
                                            </td>
                                            <td class="text-center">
                                                <input type="text" name="form-__prefix__-content" maxlength="100"
                                                       placeholder="적요" class="form-control"
                                                       id="id_form-__prefix__-content" onblur="sync_transfer(this)"
                                                       disabled="">
                                            </td>
                                            <td class="text-center">
                                                <input type="text" name="form-__prefix__-trader" maxlength="30"
                                                       data-content="분양대금(분담금)일 경우 반드시 해당 계좌에 기재된 입금자를 기재"
                                                       data-trigger="hover" data-toggle="popover"
                                                       placeholder="거래처(납부자)" class="form-control"
                                                       id="id_form-__prefix__-trader" data-original-title=""
                                                       title="" disabled="">
                                            </td>
                                            <td class="text-center">
                                                <select name="form-__prefix__-bank_account" class="form-control"
                                                        id="id_form-__prefix__-bank_account" disabled="">
                                                    <option value="" selected="">---------</option>
                                                    {% for pba in pb_account %}
                                                        <option value="{{ pba.id }}">{{ pba }}</option>
                                                    {% endfor %}
                                                </select>
                                            </td>
                                            <td class="text-center">
                                                <input type="number" name="form-__prefix__-income" min="0"
                                                       placeholder="입금액" class="form-control text-right"
                                                       id="id_form-__prefix__-income" disabled="">
                                            </td>
                                            <td class="text-center">
                                                <input type="number" name="form-__prefix__-outlay" min="0"
                                                       placeholder="출금액" class="form-control text-right"
                                                       id="id_form-__prefix__-outlay" disabled="">
                                            </td>
                                            <td>
                                                <textarea
                                                        name="form-__prefix__-note"
                                                        cols="40" rows="1"
                                                        placeholder="상세 비고"
                                                        class="form-control"
                                                        id="id_form-__prefix__-note"
                                                        disabled></textarea>
                                            </td>
                                            <td class="pt-2">
                                                <a href="javascript:void(0)"
                                                   class="font-18"
                                                   style="color: #999">
                                                    <i class="mdi mdi-close-circle"
                                                       data-formset-remove-form></i>
                                                </a>
                                            </td>
                                        </tr>
                                        </tbody>

                                        <tbody class="forms p-0">
                                        {% for form in formset %}
                                            <tr>
                                                <td class="text-center">
                                                    {{ form.cash_category1|add_class:"form-control"|attr:"required" }}
                                                    {{ form.cash_category1.errors }}
                                                </td>
                                                <td class="text-center">
                                                    {{ form.project_account_d1|add_class:"form-control"|attr:"required" }}
                                                    {{ form.project_account_d1.errors }}
                                                </td>
                                                <td class="text-center">
                                                    {{ form.project_account_d2|add_class:"form-control"|attr:"required" }}
                                                    {{ form.project_account_d2.errors }}
                                                </td>
                                                <td class="text-center">
                                                    {{ form.content|add_class:"form-control"|attr:"placeholder:적요" }}
                                                    {{ form.content.errors }}
                                                </td>
                                                <td class="text-center">
                                                    {{ form.trader|add_class:"form-control"|attr:"placeholder:거래처(납부자)"|attr:"data-toggle:popover"|attr:"data-trigger:hover"|attr:"data-content:분양대금(분담금)일 경우 반드시 해당 계좌에 기재된 입금자를 기재" }}
                                                    {{ form.trader.errors }}
                                                </td>
                                                <td class="text-center">
                                                    {{ form.bank_account|add_class:"form-control" }}
                                                    {{ form.bank_account.errors }}
                                                </td>
                                                <td class="text-center">
                                                    {{ form.income|add_class:"form-control text-right"|attr:"placeholder:입금액" }}
                                                    {{ form.income.errors }}
                                                </td>
                                                <td class="text-center">
                                                    {{ form.outlay|add_class:"form-control text-right"|attr:"placeholder:출금액" }}
                                                    {{ form.outlay.errors }}
                                                </td>
                                                <td>
                                                    {{ form.note|add_class:"form-control"|attr:"rows:1"|attr:"placeholder:상세 비고" }}
                                                    {{ form.note.errors }}
                                                </td>
                                                <td></td>
                                            </tr>
                                        {% endfor %}
                                        </tbody>
                                    </table>
                                </div>
                            </div>

                            <fieldset class="controls form-row form-group mb-2 row pt-2 col-12 bg-light">
                                <div class="col-12">
                                    <div class="form-group col-12 mt-0 row add-form-row">
                                        <a href="javascript:void(0)" data-formset-add-form><i
                                                class="mdi mdi-plus-circle-outline text-info font-18"></i> 입출금 내역 더 추가하기
                                        </a>
                                    </div>
                                </div>
                            </fieldset>
                            {# 프로젝트 캐시북 폼셋 finish #}
                        </div>
                    </div>
                </div>
                <div class="col-lg-12">
                    <div class="card">
                        <div class="card-body">
                            <div class="row">
                                <div class="form-group mb-0 justify-content-end row">
                                    <div class="col-12">
                                        {% if request.user.is_superuser or request.user.staffauth.project_cash > '1' %}
                                            <button type="submit" class="btn btn-primary">등록하기</button>
                                        {% else %}
                                            <button type="button" class="btn btn-outline-secondary"
                                                    onclick="alert('입출금 내역 등록 권한이 없습니다. 관리자에게 문의하여 주십시요.')">조회권한 사용자
                                            </button>
                                        {% endif %}
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </form>
        </div>


    </div> <!-- container -->

{% endblock %}


{% block third_party_js %}

    <script>
      const num = document.getElementById('id_form-TOTAL_FORMS').value

      window.onload = function () {
        document.getElementById('id_deal_date').value = '{% now "Y-m-d" %}'
        document.getElementById('id_project_sel').setAttribute('onchange', 'submit()')

        for (let i = 0; i < num; i++) {
          document.getElementById('id_form-' + i + '-cash_category1').setAttribute('onchange', 'category1_change(this)')
          document.getElementById('id_form-' + i + '-project_account_d1').setAttribute('onchange', 'pa_d1_change(this)')
          document.getElementById('id_form-' + i + '-content').setAttribute('onblur', 'sync_transfer(this)')

          document.getElementById('id_form-' + i + '-project_account_d1').disabled = true //
          document.getElementById('id_form-' + i + '-project_account_d2').disabled = true //
          document.getElementById('id_form-' + i + '-content').disabled = true
          document.getElementById('id_form-' + i + '-trader').disabled = true
          document.getElementById('id_form-' + i + '-bank_account').disabled = true
          document.getElementById('id_form-' + i + '-income').disabled = true         // 입금액 폼
          document.getElementById('id_form-' + i + '-outlay').disabled = true         // 출금액 폼
          document.getElementById('id_form-' + i + '-note').disabled = true
        }
      }

      function category1_change(object) {
        let i = parseInt(object.name.substr(5, 1))
        const pa_d1 = document.getElementById('id_form-' + i + '-project_account_d1')          // 계정 대분류, --- 필수
        const pa_d2 = document.getElementById('id_form-' + i + '-project_account_d2')          // 계정 대분류, --- 필수
        const content = document.getElementById('id_form-' + i + '-content')                        // 적요, --- 필수
        const trader = document.getElementById('id_form-' + i + '-trader')                          // 거래처, --- 필수
        const bank_account = document.getElementById('id_form-' + i + '-bank_account')              // 거래계좌, --- 필수
        const income = document.getElementById('id_form-' + i + '-income')                          // 입금액 폼 --- 필
        const outlay = document.getElementById('id_form-' + i + '-outlay')                          // 출금액 폼 --- 필
        const note = document.getElementById('id_form-' + i + '-note')

        const next_category1 = document.getElementById('id_form-' + (i + 1) + '-cash_category1')    // 계정 대분류, --- 필수
        const next_pa_d1 = document.getElementById('id_form-' + (i + 1) + '-project_account_d1')
        const next_pa_d2 = document.getElementById('id_form-' + (i + 1) + '-project_account_d2')
        const next_content = document.getElementById('id_form-' + (i + 1) + '-content')
        const next_trader = document.getElementById('id_form-' + (i + 1) + '-trader')
        const next_bank_account = document.getElementById('id_form-' + (i + 1) + '-bank_account')   // 거래계좌, --- 필수
        const next_income = document.getElementById('id_form-' + (i + 1) + '-income')               // 입금액 폼 --- 필
        const next_outlay = document.getElementById('id_form-' + (i + 1) + '-outlay')
        const next_note = document.getElementById('id_form-' + (i + 1) + '-note')

        pa_d1.disabled = (object.value === '') ? true : false
        pa_d2.disabled = (object.value === '') ? true : false
        content.disabled = (object.value === '') ? true : false
        trader.disabled = (object.value === '3' | object.value === '') ? true : false
        bank_account.disabled = (object.value === '') ? true : false
        income.disabled = (object.value === '1') ? false : true
        outlay.disabled = (object.value === '2' | object.value === '3') ? false : true
        note.disabled = (object.value === '') ? true : false

        {#content.required = (object.value !== '') ? true : false#}
        bank_account.required = (object.value !== '') ? true : false
        income.required = (object.value === '1') ? true : false
        outlay.required = (object.value === '2' | object.value === '3') ? true : false

        if (object.value === '1') { // 입금
          inc(pa_d1)
          get_d2(pa_d2, '1', null)
        } else if (object.value === '2') { // 출금
          out(pa_d1)
          get_d2(pa_d2, '2', null)
        } else if (object.value == '3') { // 대체일 경우
          // 다음 줄 폼이 없으면 추가하는 로직 작성
          if (next_category1 === null) {
            alert('입출금 내역을 한 칸 더 추가하고 다시 시도하세요!')
            pa_d1.disabled = true
            pa_d2.disabled = true
            object.options[0].selected = true
            content.disabled = true
            bank_account.disabled = true
            outlay.disabled = true
            note.disabled = true
            return
          }
          trans(pa_d1)
          get_d2(pa_d2, '3', null)
          pa_d1.options[1].selected = true
          pa_d2.options[1].selected = true
          internal_transfer(i)
        } else { // ''
          if (next_category1) {
            pa_d1.options[0].selected = true
            pa_d2.options[0].selected = true
            next_category1.options[0].selected = true
            next_pa_d1.options[0].selected = true
            next_pa_d1.disabled = true
            next_pa_d2.options[0].selected = true
            next_pa_d2.disabled = true
            next_content.value = ''
            next_content.disabled = true
            next_bank_account.options[0].selected = true
            next_bank_account.disabled = true
            next_trader.value = ''
            next_trader.disabled = true
            next_bank_account.options[0].selected = true
            next_bank_account.disabled = true
            next_income.value = null
            next_income.disabled = true
            next_outlay.value = null
            next_outlay.disabled = true
            next_note.value = ''
            next_note.disabled = true
          }
        }
      }

      function internal_transfer(i) { // 대체 시 다음 라인 폼 세팅 id_form-0-project_account_d1
        i = parseInt(i)
        const next_category1 = document.getElementById('id_form-' + (i + 1) + '-cash_category1')    // 계정 대분류, --- 필수

        const next_pa_d1 = document.getElementById('id_form-' + (i + 1) + '-project_account_d1')    // 계정 대분류, --- 필수
        const next_pa_d2 = document.getElementById('id_form-' + (i + 1) + '-project_account_d2')

        const next_content = document.getElementById('id_form-' + (i + 1) + '-content')
        const next_trader = document.getElementById('id_form-' + (i + 1) + '-trader')
        const next_bank_account = document.getElementById('id_form-' + (i + 1) + '-bank_account')   // 거래계좌, --- 필수
        const next_income = document.getElementById('id_form-' + (i + 1) + '-income')               // 입금액 폼 --- 필
        const next_outlay = document.getElementById('id_form-' + (i + 1) + '-outlay')
        const next_note = document.getElementById('id_form-' + (i + 1) + '-note')

        next_category1.options[3].selected = true

        next_pa_d1.disabled = false // 계정 대분류, --- 필수
        next_pa_d1.length = 2
        next_pa_d1.options[1].text = "대체"
        next_pa_d1.options[1].value = "17"
        next_pa_d1.options[1].selected = true

        next_pa_d2.disabled = false // 계정 대분류, --- 필수
        next_pa_d2.length = 2
        next_pa_d2.options[1].text = "대체"
        next_pa_d2.options[1].value = "61"
        next_pa_d2.options[1].selected = true

        next_content.disabled = false
        {#next_content.required = true#}
        next_trader.disabled = true
        next_trader.required = false
        next_bank_account.disabled = false
        next_bank_account.required = true
        next_income.disabled = false
        next_income.required = true
        next_outlay.disabled = true
        next_outlay.required = false
        next_note.disabled = false
      }

      function sync_transfer(obj) {
        const i = parseInt(obj.name.substr(5, 1))
        const currunt = document.getElementById('id_form-' + i + '-cash_category1')
        const next = document.getElementById('id_form-' + (i + 1) + '-cash_category1')
        if (currunt.value === '3' && next.value === '3') {
          document.getElementById('id_form-' + (i + 1) + '-content').value = obj.value
        } else {
          return
        }
      }

      function inc(pa_d1) {
        pa_d1.length = {{ pa_d1_inc.count|add:"1" }};
        {% for d1 in pa_d1_inc %}
          pa_d1.options[{{ forloop.counter }}].text = "{{ d1.name }}";   //2-1번째 셀렉트바 텍스트 정의
          pa_d1.options[{{ forloop.counter }}].value = "{{ d1.id }}";     //2-1번째 셀렉트바 값 정의
        {% endfor %}
      }

      function out(pa_d1) {
        pa_d1.length = {{ pa_d1_out.count|add:"1" }};
        {% for d1 in pa_d1_out %}
          pa_d1.options[{{ forloop.counter }}].text = "{{ d1.name }}";   //2-1번째 셀렉트바 텍스트 정의
          pa_d1.options[{{ forloop.counter }}].value = "{{ d1.id }}";     //2-1번째 셀렉트바 값 정의
        {% endfor %}
      }

      function trans(pa_d1) {
        pa_d1.length = {{ pa_d1_trans.count|add:"1" }};
        {% for d1 in pa_d1_trans %}
          pa_d1.options[{{ forloop.counter }}].text = "{{ d1.name }}";   //2-1번째 셀렉트바 텍스트 정의
          pa_d1.options[{{ forloop.counter }}].value = "{{ d1.id }}";     //2-1번째 셀렉트바 값 정의
        {% endfor %}
      }

      function pa_d1_change(d1) {                                  // 구분 2 셀 값 변경 시 로직
        const i = d1.name.substr(5, 1)
        const d2 = document.getElementById('id_form-' + i + '-project_account_d2')  // 프로젝트 계정 과목

        if (d1.value === '') {
          d2.options[0].selected = true
          d2.disabled = true
        } else {
          d2.disabled = false
          get_d2(d2, null, d1.value)
        }
      }

      function get_d2(d2, d1_sort, d1) {
        if (d1_sort !== null) {
          if (d1_sort === '1') {
            d2.length = {{ pa_d2_inc.count|add:"1" }}
                {% for d2 in pa_d2_inc %}
                  d2.options[{{ forloop.counter }}].value = '{{ d2.id }}'
                  d2.options[{{ forloop.counter }}].text = '{{ d2 }}'
                {% endfor %}
          } else if (d1_sort === '2') {
            d2.length = {{ pa_d2_out.count|add:"1" }}
                {% for d2 in pa_d2_out %}
                  d2.options[{{ forloop.counter }}].value = '{{ d2.id }}'
                  d2.options[{{ forloop.counter }}].text = '{{ d2 }}'
                {% endfor %}
          } else if (d1_sort === '3') {
            d2.length = {{ pa_d2_trans.count|add:"1" }}
                {% for d2 in pa_d2_trans %}
                  d2.options[{{ forloop.counter }}].value = '{{ d2.id }}'
                  d2.options[{{ forloop.counter }}].text = '{{ d2 }}'
                {% endfor %}
          }
        } else if (d1 !== null) {
          switch (d1) {
            case '1':
              d2.length = {{ d2_1.count|add:"1" }}
                  {% for d2 in d2_1 %}
                    d2.options[{{ forloop.counter }}].value = '{{ d2.id }}'
                    d2.options[{{ forloop.counter }}].text = '{{ d2 }}'
                  {% endfor %}
              break

            case '2':
              d2.length = {{ d2_2.count|add:"1" }}
                  {% for d2 in d2_2 %}
                    d2.options[{{ forloop.counter }}].value = '{{ d2.id }}'
                    d2.options[{{ forloop.counter }}].text = '{{ d2 }}'
                  {% endfor %}
              break
            case '3':
              d2.length = {{ d2_3.count|add:"1" }}
                  {% for d2 in d2_3 %}
                    d2.options[{{ forloop.counter }}].value = '{{ d2.id }}'
                    d2.options[{{ forloop.counter }}].text = '{{ d2 }}'
                  {% endfor %}
              break
            case '4':
              d2.length = {{ d2_4.count|add:"1" }}
                  {% for d2 in d2_4 %}
                    d2.options[{{ forloop.counter }}].value = '{{ d2.id }}'
                    d2.options[{{ forloop.counter }}].text = '{{ d2 }}'
                  {% endfor %}
              break

            case '5':
              d2.length = {{ d2_5.count|add:"1" }}
                  {% for d2 in d2_5 %}
                    d2.options[{{ forloop.counter }}].value = '{{ d2.id }}'
                    d2.options[{{ forloop.counter }}].text = '{{ d2 }}'
                  {% endfor %}
              break
            case '6':
              d2.length = {{ d2_6.count|add:"1" }}
                  {% for d2 in d2_6 %}
                    d2.options[{{ forloop.counter }}].value = '{{ d2.id }}'
                    d2.options[{{ forloop.counter }}].text = '{{ d2 }}'
                  {% endfor %}
              break
            case '7':
              d2.length = {{ d2_7.count|add:"1" }}
                  {% for d2 in d2_7 %}
                    d2.options[{{ forloop.counter }}].value = '{{ d2.id }}'
                    d2.options[{{ forloop.counter }}].text = '{{ d2 }}'
                  {% endfor %}
              break
            case '8':
              d2.length = {{ d2_8.count|add:"1" }}
                  {% for d2 in d2_8 %}
                    d2.options[{{ forloop.counter }}].value = '{{ d2.id }}'
                    d2.options[{{ forloop.counter }}].text = '{{ d2 }}'
                  {% endfor %}
              break
            case '9':
              d2.length = {{ d2_9.count|add:"1" }}
                  {% for d2 in d2_9 %}
                    d2.options[{{ forloop.counter }}].value = '{{ d2.id }}'
                    d2.options[{{ forloop.counter }}].text = '{{ d2 }}'
                  {% endfor %}
              break
            case '10':
              d2.length = {{ d2_10.count|add:"1" }}
                  {% for d2 in d2_10 %}
                    d2.options[{{ forloop.counter }}].value = '{{ d2.id }}'
                    d2.options[{{ forloop.counter }}].text = '{{ d2 }}'
                  {% endfor %}
              break
            case '11':
              d2.length = {{ d2_11.count|add:"1" }}
                  {% for d2 in d2_11 %}
                    d2.options[{{ forloop.counter }}].value = '{{ d2.id }}'
                    d2.options[{{ forloop.counter }}].text = '{{ d2 }}'
                  {% endfor %}
              break
            case '12':
              d2.length = {{ d2_12.count|add:"1" }}
                  {% for d2 in d2_12 %}
                    d2.options[{{ forloop.counter }}].value = '{{ d2.id }}'
                    d2.options[{{ forloop.counter }}].text = '{{ d2 }}'
                  {% endfor %}
              break
            case '13':
              d2.length = {{ d2_13.count|add:"1" }}
                  {% for d2 in d2_13 %}
                    d2.options[{{ forloop.counter }}].value = '{{ d2.id }}'
                    d2.options[{{ forloop.counter }}].text = '{{ d2 }}'
                  {% endfor %}
              break
            case '14':
              d2.length = {{ d2_14.count|add:"1" }}
                  {% for d2 in d2_14 %}
                    d2.options[{{ forloop.counter }}].value = '{{ d2.id }}'
                    d2.options[{{ forloop.counter }}].text = '{{ d2 }}'
                  {% endfor %}
              break
            case '15':
              d2.length = {{ d2_15.count|add:"1" }}
                  {% for d2 in d2_15 %}
                    d2.options[{{ forloop.counter }}].value = '{{ d2.id }}'
                    d2.options[{{ forloop.counter }}].text = '{{ d2 }}'
                  {% endfor %}
              break
            case '16':
              d2.length = {{ d2_16.count|add:"1" }}
                  {% for d2 in d2_16 %}
                    d2.options[{{ forloop.counter }}].value = '{{ d2.id }}'
                    d2.options[{{ forloop.counter }}].text = '{{ d2 }}'
                  {% endfor %}
              d2.options[1].selected = true
              break
          }
        }
        return d2
      }
    </script>

    <!-- formset add form script -->
    <script src="{% static 'common/js/formset_add_form.js' %}"></script>

{% endblock %}
